package com.example.tests;


import static org.testng.Assert.fail;

import java.util.Random;
import java.util.Set;

import org.testng.annotations.Test;

import com.example.data.GroupData;

public class GroupRemovalTests extends TestBase {
	@Test
	public void groupRemovalTest() throws Exception {
		
		Set<GroupData> oldList = manager.getGroupHelper().getGroupsList();
		if (oldList.size() > 0) {
			
		//the number of group we want to delete - random integer from [1, current number of groups at page]
		int number = new Random().nextInt(oldList.size());
		GroupData groupToDelete = manager.getGroupHelper().deleteGroupByNumber(number);
		//get new list of groups
		Set<GroupData> newList = manager.getGroupHelper().getGroupsList();
		//compare lists
		verifyGroupDeleted(oldList, groupToDelete, newList);
		} else {
			//fail the test if contact list is empty
			fail("Groups list is empty");
		}
	}
	
	

}
